import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/4/30
 */
public class Demo19 {
    static int N = 1010;
    static int[][] a = new int[N][N], s = new int[N][N];

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int n = scan.nextInt(),m = scan.nextInt(),q= scan.nextInt();
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++){
                a[i][j] = scan.nextInt();
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
            }

        while(true){
            if(q-- == 0)break;
            int x1 = scan.nextInt(),y1 = scan.nextInt(),x2 = scan.nextInt(),y2 = scan.nextInt();
            System.out.println(s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]);
        }
    }
}
